package bay;

import sell.DbTest;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by webrx on 2017/6/17.
 */
@WebServlet("/check.do")
public class UserCheck extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out =resp.getWriter();
        DbTest db = new DbTest();
        String action =req.getParameter("av");
        System.out.println(action+"*******");
       boolean bo= db.exists("user_table","where name='"+action+"'");
       if(bo){
           out.print("no");
           System.out.println("no");
       }else{
           System.out.println("yes");
           out.print("yes");
       }
       out.flush();
       out.close();
    }
}
